POV-Ray : Newsgroups : povray.newusers : read colors from file : Re: read colors from file Server Time
8 Jul 2024 19:44:27 EDT (-0400)
  Re: read colors from file  
From: Tim Attwood
Date: 10 Jun 2007 03:01:53
Message: <466ba1e1$1@news.povray.org>
You can only read CSV floats, vectors, and
quote delimited strings from a file.

Arrays can only hold elements of the same type.

You can use three arrays instead though.

Then you can construct a string to parse with
the Parse_String macro in strings.inc, and that
will convert a string like "Red" to a color identifier.

#include "strings.inc"
#declare fileName = "datas.txt";
#declare pourcentage = array[20];
#declare decalage = array[20];
#declare infocouleur= array[20];

#set index=0;
#fopen FILE fileName read
#while (defined(FILE))
  #read (FILE,P,D,C)
  #declare pourcentage[index]= P;
  #declare decalage[index]=D;
  cmd=concat("#declare infocouleur[index]=",C,";")
  Parse_String(cmd)
  #set index=index+1;
#end
#fclose FILE


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.